<?php
function PMA_auth() { if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) { PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']); exit; } if (empty($GLOBALS['cfg']['Server']['verbose'])) { $server_message = $GLOBALS['cfg']['Server']['host']; } else { $server_message = $GLOBALS['cfg']['Server']['verbose']; } $server_message = preg_replace('/[^\x20-\x7e]/i', '', $server_message); header('WWW-Authenticate: Basic realm="phpMyAdmin ' . $server_message . '"'); header('HTTP/1.0 401 Unauthorized'); if (php_sapi_name() !== 'cgi-fcgi') { header('status: 401 Unauthorized'); } header('Content-Type: text/html; charset=' . $GLOBALS['charset']); $page_title = $GLOBALS['strAccessDenied']; require './libraries/header_meta_style.inc.php'; ?>
</head>
<body>
<?php if (file_exists('./config.header.inc.php')) { require './config.header.inc.php'; } ?>
<br /><br />
<center>
<h1><?php echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION); ?></h1>
</center>
<br />
<div class="warning"><?php echo $GLOBALS['strWrongUser']; ?></div>
<?php if (file_exists('./config.footer.inc.php')) { require './config.footer.inc.php'; } ?>
</body>
</html>
<?php
exit(); } function PMA_auth_check() { global $PHP_AUTH_USER, $PHP_AUTH_PW; global $old_usr; if (empty($PHP_AUTH_USER)) { if (PMA_getenv('PHP_AUTH_USER')) { $PHP_AUTH_USER = PMA_getenv('PHP_AUTH_USER'); } elseif (PMA_getenv('REMOTE_USER')) { $PHP_AUTH_USER = PMA_getenv('REMOTE_USER'); } elseif (PMA_getenv('REDIRECT_REMOTE_USER')) { $PHP_AUTH_USER = PMA_getenv('REDIRECT_REMOTE_USER'); } elseif (PMA_getenv('AUTH_USER')) { $PHP_AUTH_USER = PMA_getenv('AUTH_USER'); } elseif (PMA_getenv('HTTP_AUTHORIZATION')) { $PHP_AUTH_USER = PMA_getenv('HTTP_AUTHORIZATION'); } elseif (PMA_getenv('Authorization')) { $PHP_AUTH_USER = PMA_getenv('Authorization'); } } if (empty($PHP_AUTH_PW)) { if (PMA_getenv('PHP_AUTH_PW')) { $PHP_AUTH_PW = PMA_getenv('PHP_AUTH_PW'); } elseif (PMA_getenv('REMOTE_PASSWORD')) { $PHP_AUTH_PW = PMA_getenv('REMOTE_PASSWORD'); } elseif (PMA_getenv('AUTH_PASSWORD')) { $PHP_AUTH_PW = PMA_getenv('AUTH_PASSWORD'); } } if (strcmp(substr($PHP_AUTH_USER, 0, 6), 'Basic ') == 0) { $usr_pass = base64_decode(substr($PHP_AUTH_USER, 6)); if (! empty($usr_pass)) { $colon = strpos($usr_pass, ':'); if ($colon) { $PHP_AUTH_USER = substr($usr_pass, 0, $colon); $PHP_AUTH_PW = substr($usr_pass, $colon + 1); } unset($colon); } unset($usr_pass); } if (!empty($old_usr) && (isset($PHP_AUTH_USER) && $old_usr == $PHP_AUTH_USER)) { $PHP_AUTH_USER = ''; session_destroy(); } if (empty($PHP_AUTH_USER)) { return false; } else { return true; } } function PMA_auth_set_user() { global $cfg, $server; global $PHP_AUTH_USER, $PHP_AUTH_PW; if ($cfg['Server']['user'] != $PHP_AUTH_USER) { $servers_cnt = count($cfg['Servers']); for ($i = 1; $i <= $servers_cnt; $i++) { if (isset($cfg['Servers'][$i]) && ($cfg['Servers'][$i]['host'] == $cfg['Server']['host'] && $cfg['Servers'][$i]['user'] == $PHP_AUTH_USER)) { $server = $i; $cfg['Server'] = $cfg['Servers'][$i]; break; } } } $cfg['Server']['user'] = $PHP_AUTH_USER; $cfg['Server']['password'] = $PHP_AUTH_PW; return true; } function PMA_auth_fails() { $error = PMA_DBI_getError(); if ($error && $GLOBALS['errno'] != 1045) { PMA_fatalError($error); } else { PMA_auth(); return true; } } ?>
